define(['angular'], function(angular) {
    angular.module('filter', [])
        .filter('filterPledge', [function() {
            return function(input) {
            	//'0':有抵押  '1':无抵押
            	var isClass = "";
            	if(input != "" && input != null){
            		if(input === '0'){
            			isClass = "show_block";
            		}else if(input === '1'){
            			isClass = "";
            		}
            	}
               return isClass;
            };
        }])
        .filter('formatDate', [function() {
            return function(input) {
            	var returnDate = "";
            	if(input != "" && input != null && input != 'null'){
            		returnDate = input.substring(0,4) + "-" + input.substring(4,6) + "-" + input.substring(6,8);
            	}
            	return returnDate;
            };
        }])
        .filter('formatDate_HM', [function() {
            return function(input) {
            	var returnDate = "";
            	if(input != "" && input != null && input != 'null'){
            		returnDate = input.substring(0,4) + "-" + input.substring(4,6) + "-" + input.substring(6,8)+'  '+ input.substring(8,10)+':'+ input.substring(10,12);
            	}
            	return returnDate;
            };
        }])
        .filter('formatTime', [function() {
            return function(input) {
            	var returnDate = "";
            	if(input != "" && input != null && input != 'null'){
            		returnDate = input.substring(0,2) + ":" + input.substring(2,4) + ":" + input.substring(4,6);
            	}
            	return returnDate;
            };
        }])
        .filter('filterDiffer', [function() {
            return function(input) {
            	var differ = "";
            	if(input != "" && input != null){
            		if(input.currToRepayAmt * 1 > input.currRepayedAmt * 1){
            			differ = _SYT_util.math.accSub(input.currToRepayAmt * 1 ,input.currRepayedAmt * 1);
            		}else{
            			differ = 0;
            		}
            	}
            	return differ;
            };
        }])
        .filter('filterDeg', [function() {
            return function(input) {
            	//目前规定每一万元为一度
            	var deg = "";
            	if(input != "" && input != null){
            		deg = _SYT_util.formatMoney(_SYT_util.math.accDiv(input *1,10000),0);
            	}
               return deg;
            };
        }])
        .filter('filterRange', [function() {
            return function(input) {
            	//input单位为元
            	var isClass = "";
            	if(input != "" && input != null){
            		var unit = _SYT_util.formatMoney(_SYT_util.math.accDiv(input *1,10000),0);
            		if(unit <= 250){
            			isClass = "";
            		}else if(unit > 250 && unit <= 500){
            			isClass = "range2";
            		}else if(unit > 500 && unit <= 750){
            			isClass = "range3";
            		}else if(unit > 750 && unit <= 9999){
            			isClass = "range4";
            		}else if(unit > 9999){
            			isClass = "big_item";
            		}
            	}
               return isClass;
            };
        }])
        .filter('filterAmount', [function() {
            return function(input) {
            	var unit = "";
            	if(input != "" && input != null){
            		var amt = _SYT_util.formatMoney(_SYT_util.math.accDiv(input *1,10000),0);
            		if(amt == 0){
            			amt = _SYT_util.formatMoney(_SYT_util.math.accDiv(input *1,10000),1);
            		}
            		if(amt > 9999){
            			unit = _SYT_util.formatMoney(_SYT_util.math.accDiv(amt *1,10000),2);
            		}else{
            			unit = amt;
            		}
            	}
               return unit;
            };
        }])
        .filter('filterAmount_wanyuan', [function() {
            return function(input) {
            	var unit = "";
            	if(input != "" && input != null){
					unit = _SYT_util.formatMoney(_SYT_util.math.accDiv(input *1,10000),0);
            	}
               return unit;
            };
        }])
        .filter('filterUnit', [function() {
            return function(input) {
            	var unit = "万元";
            	if(input != "" && input != null){
            		var amt = _SYT_util.formatMoney(_SYT_util.math.accDiv(input *1,10000),0);
            		if(amt > 9999){
            			unit = "亿元";
            		}
            	}
               return unit;
            };
        }])
        .filter('filterZhengData', [function() {
            return function(input) {
            	var data = "";
            	if(input != "" && input != null){
            		if(input*1 <1){
            			data =  _SYT_util.formatMoney(input*1,2);
            		}else{
            			data =  _SYT_util.formatMoney(input*1,2);
            		}
            	}
               return data;
            };
        }])
        .filter('filterMobileNo', [function() {
            return function(input) {
            	var mobileNo = "";
            	if(input != "" && input != null && !isNaN(input*1)){
            		mobileNo = input.substring(0,3) + "***" + input.substring(7,12);
            	}else{
                    mobileNo = input;
                }
               return mobileNo;
            };
        }])
        .filter('filterPwd', [function() {
            return function(input) {
            	var pwd = "";
            	if(input != "" && input != null){
            		for(var i=0;i<input.length;i++){
            			if(input[i] != ""){
            				input[i] = '•';
            			}
            		}
            		pwd = input;
            	}
               return pwd;
            };
        }])
        .filter('filtelName', [function() {
            return function(input) {
            	var userName = "";
            	if(input != "" && input != null){
            		if(input.userName != "" && input.userName != null){
            			userName = input.userName;
            		}else{
            			if(input.userType === '1'){
            				userName = "律师用户";
            			}else{
            				userName = "普通用户";
            			}
            		}
            	}
               return userName;
            };
        }])
        .filter('filterType', [function() {
            return function(input) {
            	var idType = "";
            	if(input != "" && input != null){
            		idType = (input === "1")?"身份证号":(input === "2")?"营业执照":"组织机构代码";
            	}
               return idType;
            };
        }])
        .filter('filterUserType', [function() {
            return function(input) {
            	var userType = "";
            	if(input != "" && input != null){
            		userType = (input === "1")?"自然人":(input === "2")?"法人":"其他非法人组织";
            	}
               return userType;
            };
        }])
        .filter('filterAddYuan', [function() {
            return function(input) {
            	var unit = "";
            	if(input != "" && input != null){
            		unit = input+"元";
            	}else{
            		unit = "0元"
            	}
               return unit;
            };
        }])
        .filter('filterCheckStatus', [function() {
            return function(input) {//0待律师审核；1待平台审核；2待放款；3还款中；4已还清；5已逾期；8已驳回、9已取消
            	var statusName = "";
            	if(input != "" && input != null){
            		statusName = (input === "0" || input === "1")?"待审核":(input === "2")?"待放款":(input === "3")?"还款中":(input === "4")?"已还清":(input === "5")?"已逾期":(input === "8")?"已驳回":"已取消";
            	}
               return statusName;
            };
        }])
        .filter('filterClass', [function() {
            return function(input) {//0待律师审核；1待平台审核；2待放款；3还款中；4已还清；5已逾期；8已驳回、9已取消
            	var classStyle = "";
            	if(input != "" && input != null){
            		classStyle = (input === "0" || input === "1" || input === "2")?"blue_text":(input === "3")?"green_text":(input === "4")?"black_text":(input === "5" || input === "8" || input === "9")?"red_text":"red_text";
            	}
               return classStyle;
            };
        }])
        .filter('issueClassFilter', [function() {
            return function(input) {//0待审核；1已通过；8已驳回；9已取消
            	var classStyle = "";
            	if(input != "" && input != null){
            		classStyle = (input === "0")?"blue_text":(input === "1")?"black_text":(input === "8")?"red_text":"red_text";
            	}
               return classStyle;
            };
        }])
        .filter('issueNameFilter', [function() {
            return function(input) {//0待审核；1已通过；8已驳回；9已取消
            	var name = "";
            	if(input != "" && input != null){
            		name = (input === "0")?"待审核":(input === "1")?"已发布":(input === "8")?"未通过":"已取消";
            	}
               return name;
            };
        }])
        .filter('caseFilter', [function() {
            return function(input) {//案件申请  0申请中；1已委托；2已完成；8已驳回；9已取消
            	var classStyle = "";
            	if(input != "" && input != null){
            		classStyle = (input === "0")?"blue_text":(input === "1")?"green_text":(input === "2")?"black_text":(input === "8")?"red_text":"red_text";
            	}
               return classStyle;
            };
        }])
        .filter('caseNameFilter', [function() {
            return function(input) {//案件申请  0申请中；1已委托；2已完成；8已驳回；9已取消
            	var name = "";
            	if(input != "" && input != null){
            		name = (input === "0")?"申请中":(input === "1")?"已委托":(input === "2")?"已完成":(input === "8")?"已驳回":"已取消";
            	}
               return name;
            };
        }])
        .filter('filterUserName', [function() {
            return function(input) {
            	var name = "未实名";
            	if(input != "" && input != null){
            		name = input;
            	}
               return name;
            };
        }])
        .filter('investStatusFilter', [function() {
            return function(input,riskState) {
				//案件状态：1未提交；2已提交；3业务审核通过；4风控审核通过；5已承接；0已关闭；A审核拒绝B待委托；C已委托
                //风险投状态：1合同未确认；2合同已确认；3合同已签约；4财务已审核；5财务已放款；6部分已回款；0已关闭；A审核拒绝
				var name = "";
            	if(input != "" && input != null){
            		//name = (input === "1")?"未提交":(input === "2")?"已提交":(input === "A")?"审核拒绝":(input === "3")?"业务审核通过":(input === "4")?"风控审核通过":(input === "5")?"合同已确认":(input === "6")?"合同已签约":(input === "7")?"财务已审核":(input === "8")?"财务已放款":(input === "9")?"部分已回款":(input === "0")?"已关闭":"";
            		if(riskState=="1"){
            			name='合同未确认'
					}else if(riskState=="2"){
                        name='合同已确认'
					}else if(riskState=="3"){
                        name='合同已签约'
					}else if(riskState=="4"){
                        name='财务已审核'
					}else if(riskState=="5"){
                        name='财务已放款'
					}else if(riskState=="6"){
                        name='部分已回款'
					}else if(riskState=="0"){
                        name='已关闭'
					}else if(riskState=="A"){
                        name='审核拒绝'
					}else {
                        if(input === "1"){
                            name='未提交'
                        }else if(input === "2"){
                            name='已提交'
                        }else if(input === "3"){
                            name='业务审核通过'
                        }else if(input === "D"){
                            name='风控审核中'
                        }else if(input === "4"){
                            name='风控审核通过'
                        }else if(input === "5"){
                            name='已承接'
                        }else if(input === "0"){
                            name='已关闭'
                        }else if(input === "A"){
                            name='审核拒绝'
                        }else if(input === "B"){
                            name='待委托'
                        }else if(input === "C"){
                            name='已委托'
                        }else if(input === "E"){
                            name='合同未确认'
                        }else if(input === "F"){
                            name='合同已确认'
                        }else if(input === "G"){
                            name='合同已签约'
                        }else if(input === "H"){
                            name='财务已审核'
                        }
					}
            	}
               return name;
            };
        }])
        .filter('filterCaseStatus', [function() {
            return function(input) {
				//1未提交；2已提交；3业务审核通过；4风控审核通过；5已承接；0已关闭；A审核拒绝 B待委托；C已委托
                //风险投状态：1合同未确认；2合同已确认；3合同已签约；4财务已审核；5财务已放款；6部分已回款；0已关闭；A审核拒绝
				var name = "";
            	if(input != "" && input != null){
            		if(input === "1"){
						name='未提交'
					}else if(input === "2"){
						name='已提交'
					}else if(input === "3"){
						name='业务审核通过'
					}else if(input === "D"){
                        name='风控审核中'
                    }else if(input === "4"){
						name='风控审核通过'
					}else if(input === "5"){
						name='已承接'
					}else if(input === "0"){
						name='已关闭'
					}else if(input === "A"){
						name='审核拒绝'
					}else if(input === "B"){
                        name='待委托'
                    }else if(input === "C"){
                        name='已委托'
                    }else if(input === "E"){
                        name='合同未确认'
                    }else if(input === "F"){
                        name='合同已确认'
                    }else if(input === "G"){
                        name='合同已签约'
                    }else if(input === "H"){
                        name='合同已签约'
                    }
            	}
               return name;
            };
        }])
        .filter('nplStatusFilter', [function() {
            return function(input) {//1处理中；2已完结
            	var name = "";
            	if(input != "" && input != null){
            		name = (input === "1")?"处理中":"已完结";
            	}
               return name;
            };
        }])
        .filter('filteMortgageRate', [function() {
            return function(input) {//1处理中；2已完结
            	var rate = "";
            	if(input != "" && input != null){
            		rate = input*100 + '%'
            	}
               return rate;
            };
        }])
        .filter('filterCooperate', [function() {
            return function(input) {//合作方式1：联合收购；2：联合清收；3：作为中介
            	var name = "";
            	if(input != "" && input != null){
            		name = (input == '1')?"联合收购":(input == '2')?"联合清收":"作为中介";
            	}
               return name;
            };
        }])
        .filter('filterIndex', [function() {
            return function(input) {
            	var name = (input == 0)?"一":(input == 1)?"二":(input == 2)?"三":(input == 3)?"三":(input == 4)?"四":(input == 5)?"五":(input == 6)?"六":(input == 7)?"七":(input == 8)?"八":"...";
               return name;
            };
        }])
        .filter('filterHtml', ['$sce',function($sce) {
            return function(input) {
                return $sce.trustAsHtml(input);
            };
        }])
        .filter('filtercaseType', [function() {
            return function(input) {
				var list=transData.storage_baseData.queryCaseTypeList.caseTypeList,str='';
				for(var i=0;i<list.length;i++){
					if(list[i].caseTypeId==input){
						str=list[i].caseTypeName;
						break;
					}
				}
				return str;
            };
        }])
        .filter('filtercaseStage', [function() {
            return function(input) {
				var list=transData.storage_baseData.queryCaseStageList.caseStageList,str='';
				for(var i=0;i<list.length;i++){
					if(list[i].caseStageId==input){
						str=list[i].caseStageName;
						break;
					}
				}
				return str;
            };
        }])
        .filter('filterfundUse', [function() {
            return function(input) {
				var list=transData.storage_baseData.queryFundUseList.fundUseList,str='';
				for(var i=0;i<list.length;i++){
					if(list[i].fundUseId==input){
						str=list[i].fundUseName;
						break;
					}
				}
				return str;
            };
        }])
        .filter('filterdocKind', [function() {
            return function(input,docGroup) {
				var list=transData.storage_baseData.queryDocKindList.docKindList,str='';
				for(var i=0;i<list.length;i++){
					if(list[i].docGroup==docGroup){
						if(list[i].docKindId==input){
							str=list[i].docKindName;
                            break;
						}
					}
				}
				return str;
            };
        }])
        .filter('filter_approveAction', [function() {
            return function(input) {
				//bizApprove业务审核；riskApprove风控审核；financeApprove财务审核；loan财务放款
				return input=='bizApprove'?'业务审核':input=='riskApprove'?'风控审核':input=='financeApprove'?'财务审核':input=='loan'?'财务放款':'';
            };
        }])
        .filter('filter_approveResult', [function() {
            return function(input) {
				//0审批通过；1审批拒绝
				return input=='0'?'审批通过':input=='1'?'审批拒绝':'';
            };
        }])
        .filter('filter_feeMode', [function() {
            return function(input) {
				//1固定比例；2阶梯比例；3阶梯累进
				return input=='1'?'固定比例':input=='2'?'阶梯比例':input=='3'?'阶梯累进':'';
            };
        }])
        .filter('filter_costMode', [function() {
            return function(input) {
				//<Radio value={1} key="1">从案件回款中先收回赢火虫成本</Radio>
            	//<Radio value={2} key="2">从律师费中先收回赢火虫成本</Radio>
				//<Radio value={3} key="3">不先收回成本</Radio>
				return input=='1'?'从案件回款中先收回赢火虫成本':input=='2'?'从律师费中先收回赢火虫成本':input=='3'?'不先收回成本':'';
            };
        }])
        .filter('filterHavePropertyClue', [function() {
            return function(input) {
                var name = "";
                if(input != "" && input != null){
                    name = (input === "Y")?"有":"没有";
                }
               return name;
            };
        }])
        .filter('filtercaseStageStr', [function() {
            return function(input,str,slt) {
                var bl = false;
                if(input != "" && input != null){
                    var list=transData.storage_baseData.queryCaseStageList.caseStageList,str='';
                    for(var i=0;i<list.length;i++){
                        if(list[i].caseStageId==input&&list[i].caseStageName==str){
                            bl=true;
                            break;
                        }
                    }
                }
                if(slt){
                    return bl;
				}else {
                    return !bl;
				}
            };
        }])
        .filter('filterhavePropertyClue', [function() {
            return function(input) {
                if(input==='Y'){
                    return '是';
				}else if(input==='N'){
                    return '否';
				}else {
                    return '';
				}
            };
        }])
        ;
});